package tool;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateConverter implements Converter<String, Date> {
    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    public Date convert(String s) {
        Date date = null;
        if (s == null || s.equals("")) {
            return null;
        } else {
            try {
                date = format.parse(s);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
        return date;
    }
}
